System and method for structured document authoring

ABSTRACT

A method for creating a structured document, wherein a structured document comprises a plurality of content elements wrapped in pairs of tags, includes parsing a document of a particular type containing content into a plurality of content elements; and for each content element, suggesting an optimal tag according to a tag suggestion procedure. The tag suggestion procedure includes providing sample data which has been converted into a structured sample document; deriving a set of tags from the structured sample document; evaluating the set of tags according to tag suggestion criteria to determine an optimal tag for the content element. The optimal tag may be a single tag or a pattern of tags which maximizes a similarity function with patterns found in the sample data.

FIELD OF THE INVENTION

This invention relates generally to systems and methods of documentgeneration, and more particularly to a system and method for convertinga generic document into a structured document. This invention alsorelates to a system and method for predicting structure and contentduring authoring of a structured document.

BACKGROUND OF THE INVENTION

Many systems and databases contain data in incompatible formats. One ofthe most time consuming challenges for developers has been to exchangedata between incompatible systems over the Internet. XML permits data tobe exchanged between incompatible systems. Converting data to XML formatcan greatly reduce this complexity and create data that can be read bymany different types of applications. Because of this XML has become astandard format for information exchange in IT applications and systems.However, the number of documents available/generated in XML formatremains fairly low as compared to documents in other formats. First,converting documents from other formats into XML is often difficult andtime-consuming. Second, because of the particular verbosity andlengthiness of XML documents, creating new XML documents is also atime-consuming process. Creation of an XML document requires permanentlyinterleaving document content (textual data) with semantic tags andattributes according to a Document Type Definition or DTD (a DTD definesthe legal elements and structure of an XML document), which generationprocess is frequently tedious and error-prone.

The appearance of various XML editors help the designer partially reducedocument generation overhead by offering an advanced graphic interfacewith menu-based selection of elements/attributes and a possibility toalign the document generation with a corresponding DTD by validatingentire files or their fragments. Although DTDs serve well for documentvalidation, they provide little help during document editing orcreation. The main reason for this is that most DTDs are designed byhumans before any valid XML documents are created; as result many DTDseither contain errors or are too general, that is, they allow a muchgreater degree of ambiguity than the actual documents expose. Moreover,suggesting tree-like patterns with DTDs is simply impossible, since mostelement definitions are regular expressions describing infinite sets ofpossible element contents, while document authoring is a sequence ofinstantiations of the element definitions. What is needed is a method ofeasily converting a document from one format into a structured document,such as an XML document.

The need for strongly structured documents increases with thedevelopment of new software applications (such as the semantic web) andnew standards (SGML, XML, etc.). Structured documents can be viewed ascomposed of two components: the content part and the (tree-like)structure part. Authoring assistants have been developed, especially forhelping authors create the structural markup of their documents, themost widely used being the DTD or XML-Schema checker for checking XMLdocuments. Some tools also allow tagging of textual componentssemi-automatically using tagging/parsing techniques. Many structureddocuments repeat the same content components at various locationsthroughout the document. What is needed is a method of predictingrepeated both structure and content components during documentauthoring.

Text prediction is a widely developed art. Historically, one of thefirst studies on text prediction was published by C. Shannon (Claude E.Shannon, “Prediction and Entropy of Printed English”, Bell SystemsTechnical Journal, pp. 50-64, 1951) presenting his game (“Shannongame”). The purpose of the Shannon game is to predict the next elementof text (letters, words) using the preceding context. Shannon used thistechnique to estimate bounds on the entropy of English.

Many applications propose word/text completion using simple techniquessuch as MRU (Most Recent Used) and Lookup in some files (these files canbe the current file, the buffer, the clipboard, specific lexicons,databases, etc.). More sophisticated prediction systems have beendeveloped, such as (Multilingual) Natural Language Authoring (MarcDymetman, Veronika Lux and Aarne Ranta, “XML and Multilingual DocumentAuthoring: Convergent Trends”, Proceedings of the 18th InternationalConference on Computational Linguistics (COLING 2000), pp. 243-249,Saarbruecken, 2000) and form completion (some application programs suchas MS Excel propose a cell). Hermens and Schlimmer (L. A. Hermens and J.Schlimmer, “A machine learning apprentice for the completion ofrepetitive forms”. New York, N.Y.: Cambridge University Press, 1993)propose a learning approach (decision trees) suggesting text for formfields. They also apply ML algorithms in order to predict what the userof an electronic organizer is going to write, but the system only allowspredictions from a pre-defined structure (forms).

Foster et al. (George Foster, Philippe Langlais, Elliott Macklovitch,and Guy Lapalme, “TransType: Text Prediction for Translators.Demonstration Description” in Proceedings of the 40th Annual Meeting ofthe Association for Computational Linguistics (ACL), Philadelphia, July,2002) describe a technique for translation completion. The aim of theTransType project is to develop a new kind of interactive tool to assisttranslators. The proposed system will observe a translator as s/he typesa text and periodically proposes extensions to it, which the translatormay either accept as is, modify, or ignore. The system takes intoaccount not only the source text, but the already-established part ofthe target text.

SUMMARY OF THE INVENTION

A method for creating a structured document, according to one aspect ofthe invention, wherein a structured document includes a plurality ofcontent elements wrapped in pairs of hierarchically nested tags,includes parsing a document of a particular type containing content intoa plurality of content elements; and for a selected content element,suggesting an optimal tag according to a tag suggestion procedure. Thetag suggestion procedure includes providing sample data in the form ofstructured sample documents; analysing patterns in the sample data toderive a set of tag suggestions; deriving a set of candidate tags fromthe set of tag suggestions for the selected content element; andevaluating the set of candidate tags according to tag suggestioncriteria to determine an optimal tag for the selected content element.The optimal tag may be a single tag or a pattern of tags which maximizesa similarity function with patterns found in the sample data.

The method can be used as an structure adviser component for authoringXML documents. The tag suggestion procedure can use sample data in theform of existing structured documents or it can use the prior portionsof document which is being authoried. The method analyzes availablesample data in order to suggest tags and tree patterns the user is mostlikely to use next. An architecture and method for analyzing sampledata, determining suggestion candidates and estimating optimalsuggestions for any position in the document being authored areprovided.

Since the XML format became a de facto standard for structureddocuments, the IT research and industry have developed a number ofcommercial XML editors (XML Spy, Xeena, ElfData, Morphone, etc.) andpublic ones (see http://www.oasis-open.org/cover/publicSW.html#editingfor details) to help users produce structured documents in XML format.The system and method for structured document generation intervenesduring the document editing/authoring process to suggest one tag or anentire tree-like XML pattern the user is most likely to use next.Adviser suggestions are based on finding analogies between the currentlyedited fragment and sample data, which is either previously generateddocuments in a collection or the history of the current documentediting. The structure adviser is beneficial in cases when, for example,no DTD is provided for XML documents, when the DTD associated with thedocument is too loose or general and when sample data contain specificpatterns not captured in the DTD. The method for finding optimalsuggestions may be used at any step in the process of generating a newstructured document or in the process of converting a document of anunstructured format into a structured document.

In accordance with another feature of the invention, a method forauthoring of a structured document, wherein a structured documentcomprises a plurality of content elements wrapped in pairs ofhierarchically nested tags, includes generating content elements wrappedin pairs of tags; and for a selected tag, suggesting an optimal contentfragment according to a content suggestion procedure. The contentsuggestion procedure includes providing sample structured documents;deriving a set of content fragments from the sample structureddocuments; and evaluating the set of content fragments according to acontent fragment suggestion criteria to determine an optimal contentfragment suggestion for the tag, wherein the optimal text fragmentsuggestion is the most probable content fragment for the selected tag.

The method of authoring a structured document makes use of machinelearning techniques in order to generate textual suggestions usingexisting structured documents and/or the current document as trainingdata. These suggestions are based on regularities occurring in a corpusof similar documents. During the authoring step, each time a new tag isinserted in a document, content suggestions (if any) are proposed to theauthor, who validates one or refuses all of them. The method considerscontent advising as a categorization problem; it combines machinelearning algorithms and document structure in order to predict textualchunks during the authoring step; it uses contextual (structure andcontent) information for suggestion computation; and computedsuggestions are automatically proposed to the author when theappropriate context is detected.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of an adviser system according to one aspectof the invention;

FIG. 2 is a diagram of the prefix tree for example 2;

FIG. 3 is a diagram of the prefix tree automaton for case 4 of Table 1;

FIG. 4 is a diagram of a portion of a structured document;

FIG. 5 is a block diagram of a text adviser system according to anotheraspect of the invention; and

FIG. 6 is diagram of one mixed context for the tag Section:doc/(SectionName/“Chapter Overview”, Section/TEXT).

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

The method of the invention may be used in the generation and authoringof any structured document, such as XML documents. For convenience only,the method of the invention will be described with respect to thegeneration and authoring of XML documents.

All XML documents are made up the following building blocks: elements,tags, attributes, entities, PCDATA and CDATA. Elements are the mainbuilding blocks of both XML and HTML documents. Examples of XML elementsare “note” and “message”. Elements can contain text, other elements, orbe empty. Tags are used to markup elements. A starting tag like<element_name> marks up the beginning of an element, and an ending taglike </element_name> marks up the end of an element. Attributes provideextra information about elements. Attributes are always placed insidethe starting tag of an element. Attributes always come in name/valuepairs. Entities are variables used to define common text. Entityreferences are references to entities. PCDATA means parsed characterdata, i.e., the text found between the start tag and the end tag of anXML element. PCDATA is text that will be parsed by a parser. Tags insidethe text will be treated as markup and entities will be expanded. CDATAalso means character data, i.e., text that will not be parsed by aparser. Tags inside the text will not be treated as markup and entitieswill not be expanded.

XML documents may have one or more DTDs associated with them. A DTDdefines the legal building blocks of an XML document, i.e., the documentstructure with a list of legal elements. If an XML document contains aDTD, it can carry a description of its own format with it. Applicationprograms can use a standard DTD to verify that the data received isvalid. DTDs can be used to verify the data written into the XMLdocument. However, the method of the invention can be used when no DTDis provided for XML documents, when the DTD associated with the documentis too loose or general and when sample data contain specific patternsnot captured in the DTD.

A system for implementing a structure adviser using the method of theinvention is shown in FIG. 1. In this embodiment of the invention,generic documents containing content (documents which are not in theformat of a structured document) are converted to XML documents. Thisprocess involves taking the content information from the originaldocument and embedding it between an opening tag and a closing tag.Referring to FIG. 1, author 100 begins editing document 10; i.e., author100 causes document 10 to be parsed into various content elements andbegins selecting opening and closing tags for each content element.During the editing process, when the author 100 selects a particularcontent element, adviser 12 suggests an optimal tag. The suggested tagmay be an opening tag, a closing tag or a tag pattern. The author maythen accept the suggestion or ignore it.

Adviser 12 employs a tag suggestion process to select an optimal tag topresent to the author. The tag suggestion process takes sample data 16,which in this example are XML documents having a DTD. These XMLdocuments are similar to the document 10 being converted in that theywere created from similar generic documents. Sample data 16 are analyzedand evaluated in block 14 in order to create a set of tag suggestionsand tag suggestion rules. Since the sample data 16 already has a DTD,the set of tag suggestions are in addition to the DTD. If the sampledocuments had no DTD, tag suggestions would still be generated. Adviser12 uses the result of parsing the document with parser 18 and the tagsuggestion rules to derive a set of candidate tags for the selectedcontent element from the set of tag suggestions. Adviser 12 then usestag suggestion criteria for selecting an optimal tag from the set ofcandidate tags to present to the author. As the author 100 proceeds withediting of document 10, the tags chosen by the author can be used tomodify and update the adviser 12.

The adviser intervenes in the cases of editing of the documentstructure, that is, each time the author opens or closes a tag. Notethat at any given position in the document, the user cannot addarbitrary tags, but only tags allowed by the associated DTD (if any, orby basic XML rules). For example, the element definition <!ELEMENT A(B|C)*> allows either element (tag) B or C at any position withinelement A, without prioritizing any of the two. In the general case,DTDs associated with document(s) might be tight or loose; tight DTDsdefine a highly rigid and regular structure, thus allowing only one tagat most positions in a document; these DTDs are frequent indatabase-like document collections. However, tight DTDs are rather anexception, a much more frequent case is that of loose DTDs, withmultiple possible tags at most positions in a document.

The adviser is built around a set of suggestion rules; which rules arelearned by a learning component from available sample data. Learningfrom sample data can be done on-line or off-line. Off-line learningtakes place when the sample data is a collection of documents suppliedin advance or previously generated by users. The suggestion ruleslearned by the system offline remain unchanged during all the process ofdocument editing, until the sample collection is extended with newdocuments and the system can re-learn suggestion rules from the updatedcollection.

Alternatively, the rules can be learnt on-line, during the process ofediting the current structured document. Sample data available forlearning is initially empty and grows as long as the user edits thedocument. Suggestion rules are learned incrementally, each elementaryedition can (immediately or with some delay) change some suggestionrules, since any new tag addition changes the frequencies oftags/patterns and therefore can alter possible suggestions by theadviser.

EXAMPLE 1

Assume that a collection of XML documents with an associated DTD wasprovided for off-line learning and the learning component has analyzedthe collection and inferred patterns for authoring new documents. Nowassume that the user edits a new document with the same DTD and at somepoint opens/closes tag <A>. Below we consider four different examples ofelement A's structure imposed by the DTD and show how the adviser canhelp the user by suggesting the most probable tag or pattern. Table 1below gives detail on tag patterns and their frequencies in sample data.

Case 1. DTD contains the element definition <!Element A (B+)> for A,that is, element A can contains only sub-elements B. There is noambiguity and system proposes tag B as a unique choice or automaticallyexpands it. On the other hand, the system can propose pattern BB as themost probable one. (Note that X=A (BB) is an abbreviation for the XMLfragment <X><A><B>. . . </B><B>. . . </B></A></X>.)

Case 2. DTD contains definition <!Element A (B+|C+|PCDATA)>, thusallowing either B or C as the first sub-element of A or PCDATA. From theanalysis of sample data, the adviser can propose the most likely elementfirst, C, with estimated probability Pr=0.8 (Pr˜0.8 means that theestimated probability of the given suggestion is about 0.8); such adecision the adviser made from sample data where <A> followed by <C>occurred 8 times, <A><B> occurred twice, and <A> followed by PCDATAnever occurred. Also, the system may suggest pattern A=CC.

Case 3. DTD contains two definitions <!Element A (PCDATA)> and <!ElementX (A*)>: once the tag A is open, user can type in only PCDATA as oneuniquely allowed by the DTD, but when closing the second tag A within X,the adviser suggests to close also tag X.

Case 4. Analysis of sample data for the suggestions goes beyond simplestatistics on element mutual occurrences. Assume that DTD contains<!Element X (A+)>, <!Element Y (A+)>, <!Element A (B+|C+)>, and useropens an element <A>. Then, the learning component can find out thatthough elements B and C follow element A quite equally, B follows A whenA is (structurally) preceded by X, while C follows A when A is precededby Y. Thus the system's advice will depend on the context of tag A, thatis, which tag precedes it. Table 1 shows an example when tag A ispreceded by tag Y, thus adviser suggests tag C and pattern CC as themost probable ones.

TABLE 1 Four examples of structure advisor at work. Case 1 2 3 4 DTDFragment <!Element A <!Element A <!Element A <!Element X (B+)> (B+ | C+|(PCDATA)> (A+)> PCDATA)> <!Element X <!Element Y (A*)>: (A+)> <!ElementA (B+|C+)> Patterns A = BBB A = CC X = AA X = A(BB) in Sample Data A =BB A = CCC X = A X = A(BBB) A = BB Y = A(CC) Occurrences 1 6 5 2 4 2 2 22 4 Editing action Opening tag A Opening tag A Closing tag A Opening tagA when X = AA when Y = A DTD allows B B or C or Open A or Open B or openPCDATA close X C Suggested Tag B (Pr~0.8) C (Pr~0.8) Close X C (Pr~1.0)(Pr~1.0) Suggested Pattern BB (Pr~0.8) CC (Pr~0.6) X = AA CC (Pr~1.0)(P~0.72)

In total, for any addition to the document structure, being either anopening tag or a closing tag, the structure adviser can offer the mostprobable variants, these variants and their estimated probabilitiesbeing induced from the sample data. The success of the adviser ismeasured by the ratio of good suggestions, which reduces documentgeneration overload. The induction of good suggestion rules requires adeep analysis of structural patterns in sample data. In the followingsection we describe a method for determining optimal patterns fromsample data and a data structure for pattern representation andretrieval.

At any step of the document generation, the structure adviser considersa set of candidates for both one-tag and pattern suggestions (i.e., apattern of tags, usually in the form of a tree pattern) and detects theoptimal ones for either case. The optimal candidate is one that is mostprobable for the next document editing step; it maximizes a certainsimilarity with patterns found in the sample data (this similarityfunction described below). Suggesting a tree pattern is more difficultthan suggesting one tag, since the pattern suggestion should cope withthe difficulty of selection among candidates of different size. Indeed,small-size patterns are more frequent in sample data than large-sizeones. On the other hand, proposing a large pattern may be morebeneficial because, if accepted, a large pattern further reduces theediting overhead. The method is aimed at finding an optimal trade-offbetween candidates of different sizes and frequencies. In the following,we pay the main attention to finding optimal patterns, as the one-tagsuggestion is considered as a special case when the pattern size islimited to 1.

Tree pattern t is a connected fragment of a structured document. Thedepth of t is denoted d(t) (tree leaves have depth 0); the size of t isdenoted as |t| and measured as the number of nodes in the tree. Treepattern t is a prefix of pattern tree t₁ if t₁ can be obtained from t byappending zero or more nodes.

To detect an optimal suggestion for the next step of documentgeneration, we consider a set of candidates for suggestion and measurethe similarity between a candidate pattern c and a set T of treepatterns allowed in a given context. Below we introduce threerequirements a good similarity function should satisfy. Other similarityfunctions satisfying other requirements may also be used.

1. A similarity measure between a candidate c and pattern set shouldprovide a good trade-off between size and frequency of candidates.

2. The similarity measure should be easily computed.

3. The similarity evaluation should not be recomputed at each new stepof document generation. Changing context (due to advance in the editing)may alter or reduce the candidate set, but it should not change thesimilarity values.

Context-free suggestions. Consider patterns of the depth d for openingtag X. Initially, we ignore the context in which tag X is getting opened(see cases 1, 2 and 3 in Table 1); the context-sensitive case (like case4 in Table 1) will be considered in the following section. Assume that apattern set T (X)={t_(i)} is found in sample data, each pattern t_(i)being a structured sub-tree rooted at X of depth d with its probability(normalized frequency) pr_(i), where Σpr_(i)=1. When the user isauthoring a document D, the editing process is seen as a sequence ofelementary actions on the document structure, D₀, D₁=D₀+action_(o . . .). At step j of the authoring process, the user opens/closes tag X andthe adviser should propose how to extend the current state of D_(j) withone most probable tag or most probable pattern of the depth d.

Now we define a similarity measurement that satisfies the threerequirements described above. First, for a given pattern set T, we buildthe set C of candidates as the set of all patterns in T with all theirprefixes, C={c | c is a prefix of t_(i) ∈ T}. Second, we introduce asimilarity function between a candidate c ∈ C and a tree pattern t_(i) ∈T as follows:

1. sim (c, t_(i))=|c |/|t_(i) |, if c is a tree-prefix of t_(i)

2. sim (c, t_(i))=0, otherwise.

Note that sim (c, t_(i))=1 if c=t_(i). The optimal candidate is acandidate c ∈ C that maximizes the aggregate similarity measure SIM (c,T) given by

${{SIM}\left( {c,T} \right)} = {\sum\limits_{t_{i} \in T}{{{sim}\left( {c,t_{i}} \right)} \cdot {pr}_{i}}}$

EXAMPLE 2

Assume the element X is defined in DTD as <!ELEMENT X (AB*|C*)> and thefollowing table shows occurrences of all contents of element X in thesample data (note they all fit the DTD definition).

Candidate c Frequency Probability A 2 0.2 C 2 0.2 ABB 3 0.3 AB 2 0.2ABBB 1 0.1

The set of pattern candidates for opening tag X coincides with thepattern set T(X), C=T(X)={C,A,AB,ABB,ABBB}. For candidate A, we havesim(A,C)=0, sim(A,A)=1, sim(A,AB)=0.5, sim(A,ABB)=0.33 andsim(A,ABBB)=0.25. Then we obtain the aggregate similarity function valuefor candidate A, SIM(A,T)=0.425. Similarly, for other candidates in C wehave SIM(C,T)=0.2, SIM(AB,T)=0.45, SIM(ABB,T)=0.375, SIM(ABBB,T)=0.1.Therefore, pattern AB is the optimal (context-free) suggestion foropening tag X.

When considering one-tag suggestions, we constrain the candidate set Cto only one-tag pattern, C₁={c ∈ C ||c|=1}and determine the optimalcandidate in the same manner. In the example above, C, contains twoone-tag candidates, C₁={A, C}, and A is the optimal one-tag suggestion.

Context-aware suggestions. Example 2 explains context-free suggestionsfor the case of tag opening. Now we consider the case of tag closing andits difference from the tag opening case. The difference is that theclosed tag and possibly some preceding tags represent the context forthe next suggestion and, taking the context into consideration shouldresult into more accurate suggestions.

Consider again example 2 and assume the user has selected pattern ABB,filled in elements A, B and B and closed them. What should the adviserpropose next? Taking the context into consideration will constrain theset of candidates keeping the calculation of optimal candidateunchanged. The candidate set in context t_(cxt) is defined asC(t_(ctx))={c ∈ C |t_(cxt) is a prefix of c}. Similarly, C₁(t_(ctx))={c∈ C |t_(cxt) is a prefix of c, |c|=|t_(cxt) |+1}is a set of one tagcandidates. For our example, we have t_(cxt)=ABB, C(t_(ctx))={ABB, ABBB}and C₁(t_(ctx))={ABBB}. The candidate evaluation remains unchangedexcept the pattern probabilities which are re-weighted because ofshrinking the candidate set. However, the normalization of patternprobabilities will increase the absolute values of the aggregatefunction, but it will not change their relative order. This allows us tokeep the evaluation of optimal suggestions unchanged. Since ABB is theoptimal pattern candidate, the adviser will suggest to close tag X inthe context ABB. Similarly, tag B is the (only) one-tag suggestion.

Context-aware suggestions for closing tags, permits us to revise thecontext-free suggestions for opening tags. Indeed, in example 2, wecould have considered the context of opening tag X in the same way wehave considered the context ABB for closing tag B. Consider now the case4 in Table 1, where the optimal suggestion for opening tag A stronglydepends on the tag preceding A. We build the candidate set for tag Astarting from one higher level in the document, that is,T⁺¹(A)={X(A(BB)), X(A(BBB)), Y(A(CC))}. Once we have extended thecontext for element A, we can proceed with the construction of candidateset and determination of optimal suggestions for each context as before.

The context-aware suggestions can be generalized to the context of anydepth. d-context of a tag A is the sequence of ancestors of A in thedocument structure (e₁, e₂, . . . , e_(d)), where element e_(i) is animmediate ancestor of e_(i+1) and e_(d) is the immediate ancestor of A.d-context pattern set T^(+d)(A) for element An in sample data consistsof all contents of A, with each pattern being concatenated with theleading d-context of A. Once the d-context pattern set is built, thecandidate set and optimal suggestions are determined as described above.When the adviser should suggest a pattern for an opening tag A, itapplies the d-context of A from the editing document to identify theoptimal candidate.

Efficient data structure. The work of the adviser assumes that allcandidates are quickly and efficiently identified, that is, for anyediting step, the adviser can promptly retrieve the optimal candidate.Here, we propose an efficient data structure for representation andretrieval of optimal candidates for both context-free and context-awaresuggestions. For a given candidate set T, we represent the candidate setC (along with associated aggregation function values) in the form of theprefix automaton PA. This automaton has states and it containstransitions of two types, indicated with solid and dotted arcs. Theautomaton has no cycles and any state corresponds to a unique sequenceof transitions from the initial state through solid arcs and correspondsto a candidate c in C; the state is labeled with the aggregationfunction value SIM(c,T) for c; final states in the automata correspondto patterns in T. Additionally, each state c contains the optimalpattern provided that c is the current context. FIGS. 2 and 3 show theprefix automata for example 2 and case 4 in Table 1; final states inautomata are double-circled. Since all optimal suggestions are againstates in automata, an optimal suggestion for a state c is shown as areference linking (by a dotted arc) state c with the correspondingstate.

Finding the optimal candidate for context t_(ctx.) is as follows; notethat the context-free evaluation corresponds to the empty contextt_(ctx.)=∈. The context t_(ctx) is a state in PA if t_(ctx) matches acandidate c in C. The candidate set in context t_(cxt), C(t_(ctx)), isthe set of states reachable from state t_(ctx.) and the optimalcandidate for context t_(ctx.) is found by following the dotted arc fromthe state c=t_(ctx.). For example, the initial state (t_(ctx.)=∈) of PAin FIG. 2 refers to the state AB as the optimal pattern and statet_(ctx.)=ABB refers to itself that means “close-this-tag” suggestion.

The structure adviser architecture and method proposed here address thefinding of most probable structural patterns of elements in the editingXML document. Clearly, the idea of finding analogies between thecurrently editing document and sample data is not limited to elementsonly; it can be extended to other components of XML documents, includingelement attributes, key dependencies, etc.

The method described above deals with finding optimal patterns andefficient data structures for off-line learning. Once these structures(in the form of prefix automata) are built from sample data, they remainunchanged during the document edition process. If the off-line learningwill be extended with the on-line learning, it will impose additionalrequirements to the data structures, since the states, transitions andassociated aggregate values in automata can be updated after any editionstep; this will require the design of the incremental and dynamicversion of data structures for representation and retrieval of optimalsuggestions.

The system and method help users in the tedious process of on-the-flytagging during authoring of structured documents. The adviser performsstatistical analysis in the learning process to adapt its behavior tothe documents being used. This system and method may be implemented invarious ways, for example, packaged in a software product or as asoftware component or plug-in for available XML editors or an internaltools to enhance productivity in same services, such as the creation ofa richly tagged for a customer.

In accordance with another feature of the invention, the method may beused to suggest content, such as text, when authoring a structureddocument (i.e., a content adviser). For example, suppose a listoccurring in the introduction of a set of documents always uses a givenpiece of content (“List of tools:”) under the tag head (see FIG. 4). Thecontent adviser will then propose the author insert the content part“List of tools:” after the tag head. The author can validate thissuggestion or not. Not all content parts of a document can be predicted,but parts that occur frequently enough in a given position and thatoften structure the document (such as section title, list head, caption)may be predicted with a very high precision. The content adviserfacilitates the authoring task of structured documents, especially,technical documents with a twofold advantage: a reduction in authoringtime (less typing) and increased control over the content (suggestedcontent are well-formatted since provided by existing documents).

The content adviser uses a set of already structured documents in orderto automatically generate textual suggestions during document authoring.A structured document (XML document, for example) can be represented asa tree (See FIG. 4). A piece of content may be referenced in a documentusing a partial path from the document root to it (using XPATHformalism, for example). For instance, the pathsdoc/introduction/list/head/CONTENT (full path) and .*/list/head/CONTENT(partial path) indicate content occurring at some points in a document.

A system for implementing a content adviser using the method of theinvention is shown in FIG. 5. In this embodiment of the invention, anauthor creates a new structured document, such as an XML document 20.The author selects various XML tags, such as doc, introduction, list,head. When the author opens the tag “head”, the text adviser 22 suggeststhe text fragment “List of Tools:”. If the user validates the textfragment, it is inserted into document 20. If not, no action is taken.Possibly the text adviser could suggest another content fragment, or aselection of text fragments, from which the author may choose or ignore.

Content suggestions are generated using machine learning techniques byanalyzing a group of training documents 26 and provided to text adviser22. The training documents 26 are formated XML documents similar to thetype that the author is currently drafting. The training documents areanalyzed for common content fragments associated with a particular tag.For example, in FIG. 5, the content fragment “List of Tools:” appearseach time the tag “head” is used. A list of content fragments aregenerated and the content fragments evaluated according to theirrelevance and importance. Several methods of assigning relevance tocontent fragments may be used. One way to formulate this problem is toassign a score (a probability, for example) to a piece of content giventhe tag in which the text occurs: score(text, tag). The simplest way tocompute such a score is to compute the ratio between the number ofoccurrences of this content under the tag and the number of occurrencesof the same tag in the training documents. Other more sophisticatedfunctions can also be used (Laplace accuracy, etc. The optimal contentsuggestion is the text with the highest score for that tag.

While this score is generally a good indicator for a text fragmentsuggestion, frequently additional information may be required to furtherevaluate the content fragments. Additional information, such as contextinformation maybe required in order to generate even higher qualitypredictions. If the system proposes suggestions with a low probability,the rejection rate by the author may be high, and the system may be moreof a disturbance than an assistance.

To increase the likelihood of an author's acceptance of a contentfragment suggestion, the learning techniques may be modified to takeinto account the context of the tag containing the piece of content. Thestructural context of a tag generally consists of the structural treearound the tag. If the same content fragment occurs after the same treepattern of tags, it is more likely that the author will accept thissuggested content fragment. Different methods for assessing context maybe used, for example, the rule induction method of Déjean (Hervé Déjean,“Learning Syntactic Structures with XML”, in Proceedings of CoNLL-2000,Lisbon, Portugal, 2000 and Hervé Déjean, “Learning Rules and theirExceptions”, Journal of Machine Learning Research, 2(Mar):669-693,2002). For each tag containing a given piece of content (contentfragment), the content adviser will predict, given the structuralcontext of this tag, the probability that that piece of content willappear under the tag. If the probability is high enough, the contentfragment can be suggested. Furthermore the system may also be configuredso that it builds contexts so that the score of a given piece of contentto be assigned to a given tag will be higher than a given threshold,which ensures that the quality of the learned suggestions will be highenough to make the system helpful.

The structural context of a tag can be enriched with contentinformation. For example, the tree doc/(SectionName/“ChapterOverview”,Section/CONTENT) is referred to as a mixed context (structureand content) for the tag Section (FIG. 6). This context includes thestructure doc/(SectionName/“Chapter Overview”,Section which has beenenriched with the content “TEXT”. More generally, since the problem canbe formulated as a categorization problem (assign to a given tag a pieceof text that can be represented as a category), all existing machinelearning techniques that have been developed for solving this problemcan be used to generate content fragment suggestions.

If a good enough score cannot be computed for a particular contentfragment, some refined selections can also be applied. For example, thesystem can be modified to provide scores on small linguistic units, suchas a word, a phrase, or a sentence, and not the whole piece of content.A score would be assigned to the small linguistic unit, wherein thescore is, for example, a ratio of the number of occurrences of thelinguistic unit under the selected tag and the number of occurrences ofthe selected tag in the training documents. The output format of thelearning could be equivalent to a list of triples <tree,content,score>,which associate a score to content in the context tree. Several contentscan be a candidate for a same environment. An example of triplet is:

<*/Section/(SectionName/“Chapter Overview”,List,List/Head/,“List ofSections”, 0.8>

The component tree corresponds to a subtree of the document withpossibly content elements. If the tag where the element content shouldbe inserted already has some content, the element content isconcatenated to this existing content.

In order to apply such list to a document, standard parsing techniquescan be applied (rule engine, finite state automaton, etc.).

The invention has been described with reference to particularembodiments for convenience only. Modifications and alterations willoccur to others upon reading and understanding this specification takentogether with the drawings. The embodiments are but examples, andvarious alternatives, modifications, variations or improvements may bemade by those skilled in the art from this teaching which are intendedto be encompassed by the following claims.

1. A method for converting a generic document, wherein a genericdocument comprises a document in a particular format type, into astructured document, wherein a structured document includes a pluralityof content elements wrapped in pairs of hierarchically nested tags,comprising: parsing the generic document of the particular format typecontaining content into a plurality of content elements; and for aselected content element, suggesting an optimal tag according to a tagsuggestion procedure; wherein the tag suggestion procedure comprises:providing sample data in the form of structured sample documents;analyzing patterns in the sample data to derive a set of tag suggestionsand tag suggestion rules; deriving a set of candidate tags from the setof tag suggestions for the selected content element in accordance withthe tag suggestion rules; and evaluating the set of candidate tagsaccording to tag suggestion criteria to determine an optimal tag for theselected content element.
 2. The method of claim 1, wherein the tagsuggestion criteria comprises satisfying a similarity function.
 3. Themethod of claim 1, wherein the set of tag suggestions are generatedduring creation of the structured document.
 4. The method of claim 1,wherein the set of tag suggestions are generated prior to creation ofthe structured document.
 5. The method of claim 1, wherein thestructured sample document comprises an XML document having a DTDassociated with it.
 6. The method of claim 1, wherein the set of tagsuggestions includes tree patterns of tags.
 7. The method of claim 6,wherein the tag suggestion criteria comprises balancing size of treepatterns of tags and frequency of occurrence of tree patterns of tags inthe sample data.
 8. The method of claim 1, wherein the optimal tagmaximizes a similarity function with patterns found in the sample data.9. The method of claim 1, wherein the set of tag suggestions includes aset of tree patterns of tags t_(i) ∈ T, and a set C of candidates is aset of all patterns in T with all their prefixes, C={c|c is a prefix oft_(i) ∈ T}; wherein a similarity function between a candidate c ∈ C anda tree pattern t_(i) ∈ T satisfies: sim (c, t_(i))=|c |/|t_(i)|, if c isa tree-prefix of t_(i); sim (c, t_(i))=0, otherwise; and wherein theoptimal tag comprises a context-free candidate c ∈ C that maximizes anaggregate similarity measure SIM (c,T), where${{SIM}\left( {c,T} \right)} = {\sum\limits_{t_{i} \in T}{{{sim}\left( {c,t_{i}} \right)} \cdot {{pr}_{i}.}}}$10. The method of claim 9, wherein a candidate set in context t_(cxt) isdefined as C(t_(ctx))={c ∈ C|t_(cxt) is a prefix of c}; and wherein theoptimal tag comprises a context-aware candidate c ∈ C that maximizes anaggregate similarity measure SIM (c,T) where${{SIM}\left( {c,T} \right)} = {\sum\limits_{t_{i} \in T}{{{sim}\left( {c,t_{i}} \right)} \cdot {{pr}_{i}.}}}$11. The method of claim 1, wherein content comprises text.
 12. A methodfor authoring of a structured document, wherein a structured documentcomprises a plurality of content elements wrapped in pairs of tags,comprising: generating content elements wrapped in pairs of tags; andfor a selected tag, suggesting an optimal content fragment according toa content suggestion procedure; wherein the content suggestion procedurecomprises: providing a plurality of sample structured documents;analyzing the sample structured documents to derive a set of contentfragments and content fragment suggestion criteria; deriving a set ofcandidate content fragments from the sample structured documentassociated with the selected tag in accordance with the content fragmentsuggestion criteria; evaluating the set of candidate content fragmentsto determine an optimal content fragment suggestion for the tag, whereinthe optimal content fragment suggestion is the most probable contentfragment for the selected tag.
 13. The method of claim 12, furthercomprising assigning a score to each content fragment in the set ofcontent fragments, wherein the score is a ratio of number of occurrencesof the content fragment under the selected tag and number of occurrencesof the selected tag in the sample structured document.
 14. The method ofclaim 13, wherein the optimal content fragment suggestion is the contentfragment with the highest score.
 15. The method of claim 13, furthercomprising assigning a context to each content fragment in the set ofcontent fragments, wherein context comprises the structural context ofthe tag surrounding the content fragment.
 16. The method of claim 15,wherein each content fragment is referenced by a partial path from thesample structured document root and the context comprises the partialpath of the content fragment in the sample structured document.
 17. Themethod of claim 15, wherein the context of each content fragment in theset of content fragments comprises the structural tree around the tagsurrounding the content fragment.
 18. The method of claim 13, whereinthe optimal content fragment suggestion is the content fragment with thehighest score greater than a threshold value.
 19. The method of claim12, further comprising: selecting a small linguistic unit within eachcontent fragment in the set of content fragments; and assigning a scoreto the small linguistic unit, wherein the score is a ratio of number ofoccurrences of the linguistic unit under the selected tag and number ofoccurrences of the selected tag in the sample structured document. 20.The method of claim 19, wherein the small linguistic unit is a word, aphrase or a sentence.